<!-- 
    //创建绘图上下文
    let path1 = new Path2D()
    //绘制或填充path
    ctx.stroke(path1);
    ctx.fill(path1);
 -->
<html>

<head>
    <title>Canvas tutorial</title>
    <script type="text/javascript">
        function draw() {
            var canvas = document.getElementById('canvas');
            if (canvas.getContext) {
                var ctx = canvas.getContext('2d');

                var rectangle = new Path2D();
                rectangle.rect(10, 10, 50, 50);

                var circle = new Path2D();
                circle.moveTo(125, 35);
                circle.arc(100, 35, 25, 0, 2 * Math.PI);
                ctx.stroke(rectangle);
                ctx.fill(circle);
            }
        }
    </script>
    <style type="text/css">
        canvas {
            border: 1px solid black;
        }
    </style>
</head>

<body onload="draw();">
    <canvas id="canvas" width="500" height="500"></canvas>
</body>

</html>